package com.marvels.financial.loan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.financial.loan.dto.McfeDebtorAmountInfoTmpDTO;
import com.marvels.financial.loan.dto.McfeDebtorRepaymentInfoTmpDTO;
import com.marvels.financial.loan.service.CollectionReadyInfoApi;
import com.marvels.financial.utils.DateJsonValueProcessor;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

/**
 * 催收信息提供
 * 
 * @author tangpw
 *
 */
@RequestMapping("financial/loan/collectInfoProdide/service")
@RestController
public class CollectInfoProvideController {

	@Autowired
	private CollectionReadyInfoApi readyInfoApi;

	
	
	/**
	 * 当天催收金额的统计数据
	 * @return
	 */
	@RequestMapping("overdueStatic")
	@ResponseBody
	public void overdueStatic(){
		MarvelsLogUtil.getInstance().info(">>>>>当天controller催收金额的统计数据开始");
		readyInfoApi.overdueStatic();
		MarvelsLogUtil.getInstance().info(">>>>>当天controller催收金额的统计数据结束");
	}
	
	
	/**
	 * 当天催收用户人工还款信息
	 * @return
	 */
	@RequestMapping("debtorRepaymentInfo")
	@ResponseBody
	public void  debtorRepaymentInfo(){
		MarvelsLogUtil.getInstance().info(">>>>>当天controller催收用户人工还款信息开始");
		readyInfoApi.debtorRepaymentInfo();
		MarvelsLogUtil.getInstance().info(">>>>>当天controller催收用户人工还款信息结束");
	}
	
	
	
	/**
	 * 通过loanId查询当天的催收金额的统计数据
	 * @param loanId
	 * @return
	 */
	@RequestMapping("getOverdueStaticByLoanId")
	@ResponseBody
	public String getOverdueStaticByLoanId(@RequestBody String loanId) {
		MarvelsLogUtil.getInstance().info(">>>>>controller查询当天的催收金额的统计数据开始,loanId:"+loanId);
		McfeDebtorAmountInfoTmpDTO accountInfo = readyInfoApi.getOverdueStaticByLoanId(loanId);
		MarvelsLogUtil.getInstance().info(">>>>>controller查询当天的催收金额的统计数据结束,loanId:"+loanId);
		JsonConfig jsonConfig = new JsonConfig();  
		jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor());  
		JSONObject jsonObj = JSONObject.fromObject(accountInfo, jsonConfig);  
		return jsonObj.toString();
	}

	/**
	 * 通过loanId查询当天的催收用户人工还款信息
	 * @param loanId
	 * @return
	 */
	@RequestMapping("getdebtorRepaymentByLoanId")
	@ResponseBody
	public String getdebtorRepaymentByLoanId(@RequestBody String loanId) {
		MarvelsLogUtil.getInstance().info(">>>>>controller查询当天的催收用户人工还款信息开始,loanId:"+loanId);
		McfeDebtorRepaymentInfoTmpDTO repaymentInfoTmpDTO = readyInfoApi.getdebtorRepaymentByLoanId(loanId);
		MarvelsLogUtil.getInstance().info(">>>>>controller查询当天的催收用户人工还款信息结束,loanId:"+loanId);
		JsonConfig jsonConfig = new JsonConfig();  
		jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor());  
		JSONObject jsonObj = JSONObject.fromObject(repaymentInfoTmpDTO, jsonConfig);  
		return jsonObj.toString();
	}

}
